package com.ts.login.bean;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**用户信息
 * Created by xhc on 2017/3/28.
 */
public class UserInfo {

    /**用户代码*/
    private String userCode;
    /**登录代码*/
    private String loginCode;
    /**用户名称*/
    private String userName;
    /**部门代码*/
    private String deptCode;
    /**部门名称*/
    private String deptName;
    /**机关代码*/
    private String orgCode;
    /**机关名称*/
    private String orgName;
    /**用户密码*/
    private String password;
    /**用户岗位列表*/
    private List<PostInfo> userPosts;

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getUserCode() {
        return userCode;
    }

    public void setUserCode(String userCode) {
        this.userCode = userCode;
    }

    public String getLoginCode() {
        return loginCode;
    }

    public void setLoginCode(String loginCode) {
        this.loginCode = loginCode;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getDeptCode() {
        return deptCode;
    }

    public void setDeptCode(String deptCode) {
        this.deptCode = deptCode;
    }

    public String getDeptName() {
        return deptName;
    }

    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }

    public String getOrgCode() {
        return orgCode;
    }

    public void setOrgCode(String orgCode) {
        this.orgCode = orgCode;
    }

    public String getOrgName() {
        return orgName;
    }

    public void setOrgName(String orgName) {
        this.orgName = orgName;
    }

    public List<PostInfo> getUserPosts() {
        return userPosts;
    }

    public void setUserPosts(List<PostInfo> userPosts) {
        this.userPosts = userPosts;
    }

    /**
     * 获得用户所有角色
     * @return
     */
    public Set<String> getRoles(){
        Set<String> userRole=new HashSet<String>();
        List<PostInfo> posts = getUserPosts();
        for(PostInfo p : posts){
            userRole.add(p.getCode());
        }
        return userRole;
    }
}
